/*
//	CP2013 Traffic Simulator Assignment :: (MVC) Controller :: Database Access Class (Header File)
//	Copyright (c) 2010, Adam Rehn
//
//	The derived class provides access to the application's persistent storage.
*/

#ifndef _CONTROLLER_DATABSE_H
#define _CONTROLLER_DATABSE_H

//The default location of the database
#define DEFAULT_DATABASE_PATH "results.sqlite"

//We are using SQLite 3 for our persistent storage of simulation results
#include <sqlite3.h>

//We are using maps of strings for data insertion
#include <string>
#include <map>
using std::string;
using std::map;

//We are inserting using the model's setup parameters
#include "../model/common.h"

class dbAccess
{
	public:
		//Constructors and Destructor
		dbAccess();
		dbAccess(char* path);
		~dbAccess();
		
		//Use these to open and close connections
		bool open(char* path);
		void close();
		
		//Use this to check if a connection is currently open
		bool is_open();
		
		//Use this to insert data
		bool insertData(string table, map<string,string> keysAndVals);
		
		//There is currently no function to retrieve data
		
	private:
		//The SQLite database handle
		sqlite3 *db;
};

class simulationPersistentStorage : public dbAccess
{
	public:
		simulationPersistentStorage();
		bool insertResults(simulationParams setup, unsigned int numCarsPassedThroughIntersection);
};

#endif
